package org.rendao.service.image
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	import org.rendao.service.base.ServiceUtils;

	public class ImageService
	{
		private static var _instance:ImageService;
		
		public static function get instance():ImageService {
			if (!_instance) {
				_instance=new ImageService(new SingletonForcer());
			}
			return _instance;
		}
		
		public function ImageService(sf:SingletonForcer) {
		}
		
		public function getImageName(successFunction:Function):void
		{
			var successExecute:Function = function(data:Object):void
			{
				var imageName:String = data.toString();
				successFunction(imageName);
			};
			ServiceUtils.callService("service/name.do", successExecute);
		}
		
		public function loadImage(successFunction:Function):void {
			var ldr:Loader = new Loader();
			function ldr_complete(evt:Event):void {
				var bmp:Bitmap = ldr.content as Bitmap;
				successFunction(bmp);
			}
			ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, ldr_complete);
			ldr.load(new URLRequest("service/image.do"));
		}
	}
}
class SingletonForcer
{
}